class Article {
  ArrayList links = new ArrayList();
  float x;
  float y;
  String name;
  int words;
  int revisions;

  public Article(float[] position, XMLElement page) {
    name = page.getStringAttribute("title");
    for(int j=0; j<page.getChildCount(); j++) {
      links.add(page.getChild(j).getStringAttribute("to"));
    }
    revisions = page.getIntAttribute("revisions");
    if(revisions > maxrevisions) {
      maxrevisions = revisions;
    }
    words = page.getIntAttribute("words");
    x = position[0];
    y = position[1];
    
  }

  public void render() {
    float shade = 255-(map(revisions,0,maxrevisions,0,255));
    print(shade+"\n");
    fill(255,shade,shade);
    noStroke();
    float nodesize = 5+words/6; // needs tweaking
    ellipse(x,y,nodesize,nodesize);
    fill(255);
    PFont georgia = loadFont("Georgia-14.vlw");
    textFont(georgia,14);
    textAlign(CENTER);
    text(name,x,y+25);
    // should go to article when clicked on
  }
  public void drawLinks() {
    for(int i=0; i<links.size(); i++) {
      String linkname = links.get(i)+"";
      for(int j=0; j<articles.size(); j++) {
        Article article = (Article)articles.get(j);
        String articlename = article.name;
        //print("\n----\n"+articlename+"\n"+linkname+"\n"+(articlename.length()==linkname.length()));
        if(articlename.length() == linkname.length()) { // ?!?!??
          // how to indicate link direction?
          stroke(255);
          line(this.x,this.y,article.x,article.y);
        }
      }
    }
  }
}
